package com.miracle.common.view;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

public class BaseDialogProvider {
    private AlertDialog mDialog;
    private View mDialogView;
    private Context mContext;

    public BaseDialogProvider(Context context) {
        mContext = context;
    }

    public AlertDialog createDialog(int layoutId) {
        mDialogView = LayoutInflater.from(mContext).inflate(layoutId, null);
        mDialog = new AlertDialog.Builder(mContext)
                .setView(mDialogView)
                .setCancelable(true)
                .create();
        return mDialog;
    }

    public AlertDialog getDialog() {
        return mDialog;
    }

    public View getDialogView() {
        return mDialogView;
    }

    public <T extends View> T getView(int id) {
        return mDialogView.findViewById(id);
    }
}
